6-21  ʹdiffֵ΢֡
⣺Enterȷϡ
>> h = .002;
>> x = 0:h:pi;
>> diff(sin(x.^2))/h;            %is an approximation to 2*cos(x.^2).*x
>> diff((1:10).^2)
ans =
     3     5     7     9    11    13    15    17    19
>> X = [4 7 2
       1 6 5]
X =
     4     7     2
     1     6     5
>> diff(X,1,1)
ans =
    -3    -1     3
>> diff(X,1,2)
ans =
     3    -5
     5    -1
>> diff(X,2,2)    is the 2nd order difference along the dimension 2
ans =
    -8
    -6
>> diff(X,3,2)     is the empty matrix.
ans =
   Empty matrix: 2-by-0
>>
